import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const Layout = () => import('@/components/Layout/Layout.vue')


export const constantRouterMap = [ // 加载不需要权限的路由
  {
    path: '/reportAdd',
    component: Layout,
    hidden: true, // 不在左侧菜单栏显示
    children: []
  }
]

export default new VueRouter({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

// 异步挂载的路由
// 动态需要根据权限加载的路由表
// avatar 页面需要的权限 角色id  1领导 2值班员 3监管单位 4被监管单位 5安全厂商 6专家
export const asyncRouterMap = [
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [{
      id: 'home',
      path: '/home',
      component: () => import('@/views/home/home.vue'),
      meta: { title: '首页', icon: 'home', avatar: ['1', '2', '3', '4'] }
    },
    {
      id: 'notice',
      path: '/noticeManage',
      component: () => import('@/views/noticeManage/noticeManage.vue'),
      meta: { title: '公告管理', icon: 'charbin', avatar: ['1', '2', '3', '4'] }
    },
    {
      id: 'week',
      path: '/weekManage',
      component: () => import('@/views/weekManage/weekManage.vue'),
      meta: { title: '周报管理', icon: 'charbin', avatar: ['1', '2', '3', '4'] }
    },
    {
      id: 'event',
      path: '/eventManage',
      component: () => import('@/views/eventManage/eventManage.vue'),
      meta: { title: '事件管理', icon: 'charbin', avatar: ['1', '2', '3', '4'] }
    },
    {
      id: 'risk',
      path: '/riskManage',
      component: () => import('@/views/riskManage/riskManage.vue'),
      meta: { title: '风险管理', icon: 'charbin', avatar: ['1', '2', '3', '4'] }
    }
    ]
  }
]